"""mysite URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path

from TestModel import testdb  # 导入模块

from app_demo import appdemodb  # 导入模块
from app_demo.search import search_form, search
# from app_demo import search
from app_demo.searchpost import search_post

from myapp import views

from django.conf import settings
from django.urls import re_path
from django.views.static import serve  # 以上三个导入不能忘

from midware import views as mid_views

from django.contrib.sitemaps.views import sitemap
from .sitemaps import BlogSitemap


sitemaps = {
    'static': BlogSitemap,
}

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('app01.urls', namespace='app01')),
    path('', include('app_demo.urls', namespace='app_demo')),
    path('cookie/', include('cookie.urls', namespace='cookie')),
    # path('app01/', include('app01.urls', namespace='app01')),
    # path('app_demo/', include('app_demo.urls', namespace='app_demo')),
    path('testdb/', testdb.testdb, name='testdb'),
    path('appdemodb/', appdemodb.add),
    path('xxxdel/', appdemodb.xxx),
    # path('searchform/', search.search_form),
    #     # path('search/', search.search),
    path('searchform/', search_form),
    path('search/', search),
    path('search-post/', search_post),
    path('midtest/', mid_views.mid_test),
    # path('', include('midware.urls', namespace='midware')),
    path('sitemap.xml', sitemap, {'sitemaps': sitemaps},
         name='django.contrib.sitemaps.views.sitemap'),
]

if settings.DEBUG:
    urlpatterns += [
        re_path(r'^media/(?P<path>.*)$', serve, {
            'document_root': settings.MEDIA_ROOT,
        }),
    ]

# 增加的条目
handler400 = views.bad_request
handler403 = views.permission_denied
handler404 = views.page_not_found
handler500 = views.error
